import Vue from 'vue';
import vuex from 'vuex';
import createPersistedState from 'vuex-persistedstate'

Vue.use(vuex);

// 公共变量声明
const state = {
  lineName: '', // 系统线路名称
  user: {
    username: '1',
    is_authenticated: '2',
    id:'',
  },
};


export default new vuex.Store({
  plugins: [
    createPersistedState({
      paths: ['user'], // 指定需要持久化的状态
      storage: window.sessionStorage // 使用更安全的 sessionStorage
    })
  ],
  strict: false,
  state: state,
  mutations: {
    set_lineName(state, value) {
      state.lineName = value;
    },
    setUser(state, value) {
      state.user = value;
    },
  },
  actions: {

  },
  getters: {

  },
  modules: {
  }
});
